//
//  HMMyMessageCell.m
//  仿真开发
//
//  Created by Cloud on 2017/3/23.
//  Copyright © 2017年 B.HOPE. All rights reserved.
//

#import "HMMyMessageCell.h"
#import <Masonry.h>

@interface HMMyMessageCell ()

@property(weak, nonatomic)UILabel *nameLabel;

@property(weak, nonatomic)UILabel *wordLable;

@end

@implementation HMMyMessageCell

- (void)awakeFromNib {
    [super awakeFromNib];
    [self setupUI];
}


-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        
        [self setupUI];
    }
    return self;
}
- (void)setupUI
{
    
    //创建对应的名字
    UILabel *nameLabel = [[UILabel alloc ]init];
    nameLabel.textColor = [UIColor lightGrayColor];
    
    //记录
    self.nameLabel = nameLabel;
    [self.contentView addSubview:nameLabel];
    
    //间距
    CGFloat margin = 10;
    [nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
       
        make.left.mas_equalTo(self.contentView).offset(margin);
        make.size.mas_equalTo(CGSizeMake(80, 22));
        make.bottom.mas_equalTo(self.contentView).offset(-margin);
    }];
    
    //接受文字label
    UILabel *wordLabel = [[UILabel alloc] init];
    
    //记录
    self.wordLable = wordLabel;
    self.wordLable.textColor = [UIColor lightGrayColor];
    self.wordLable.textAlignment = NSTextAlignmentRight;
    [self.contentView addSubview:wordLabel];
    [wordLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(nameLabel.mas_right);
        make.size.mas_equalTo(CGSizeMake(250, 22));
        make.bottom.mas_equalTo(self.contentView).offset(-margin);
    }];
    
    if (self.labelBlock != nil) {
        NSString *label = self.wordLable.text;
        self.labelBlock(label);
    }
}

- (void)setFoModel:(NSDictionary *)foModel
{
    _foModel = foModel;
    NSString *key = [foModel allKeys].lastObject;    
//    [foModel valueForKey:key]
    self.nameLabel.text = key;
    self.wordLable.text = [NSString stringWithFormat:@"%@",foModel[key]];
}

@end
